#include <iostream>
#include <string>
#include <sstream>

using namespace std;

string intToString(int number)
{
   std::stringstream ss;
   std::string str;
   ss << number;
   ss >> str;
   return str;
}

int stringToInt(string number)
{
   std::stringstream ss;
   int value;
   ss << number;
   ss >> value;
   return value;
}

int countOnesInDecimalToBinary(int n)
{
   string binary = "";
   int onescount = 0;
   
   while(n > 0)
   {
      if(n % 2 != 0)
         onescount++;
      n = n / 2;
   }
   
   return onescount;
}

int countOnesInHexToBinary(int n)
{
   string decimal = intToString(n);
   int onescount = 0;

   for(int i = 0; i < decimal.size(); i++)
   {
      n = stringToInt(decimal.substr(decimal.size()-1-i, 1));
      while(n > 0)
      {
         if(n % 2 != 0)
            onescount++;
         n = n / 2;
      }   
   }
   
   return onescount;
}

int main()
{
   int n;
   int number;
   
   cin>>n;
   
   while(n--)
   {
      cin>>number;
      cout<<countOnesInDecimalToBinary(number)<<" ";
      cout<<countOnesInHexToBinary(number)<<endl;
   }
   
   return 0;
}
